<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
Route::get('/',function(){ abort(404); });

Route::group(['namespace' =>"Admin", 'prefix' => 'login'], function ($router){
	Route::post('token', 	'AuthController@login')->name('login');
	Route::any('logout', 	'AuthController@logout')->name('logout');
});

Route::group(['namespace' =>"Admin", 'prefix' => 'profile','middleware' => ['auth:api']], function () {
	Route::get('/user','ProfileController@user');
	Route::get('/menu','ProfileController@menu');
	Route::get('/message/count','ProfileController@message_count');
});

Route::group(['namespace' =>"Admin", 'prefix' => 'logger','middleware' => ['auth:api']], function () {
	Route::post('/error','LoggerController@logger');
});

/*用户管理模块*/
Route::group(['namespace' =>"Admin", 'prefix' => 'member','middleware' => ['auth:api']], function () {
	Route::get('/user','UserController@home');
	Route::post('/user','UserController@store');
	Route::put('/user','UserController@store');
	Route::delete('/user','UserController@delete');
	
	Route::get('/role','RoleController@home');
	Route::get('/role/{id?}','RoleController@show');
	Route::post('/role','RoleController@store');
	Route::put('/role','RoleController@store');
	Route::delete('/role','RoleController@delete');
});

/*开发人员配置模块*/
Route::group(['namespace' =>"Admin", 'prefix' => 'system','middleware' => ['auth:api']], function () {
	Route::get('/menus','MenuController@home');
	Route::get('/menus/{id?}','MenuController@show');
	Route::post('/menus','MenuController@store');
	Route::put('/menus','MenuController@store');
	Route::delete('/menus','MenuController@delete');
	Route::get('/menus/{id?}/action','MenuController@action');
	Route::post('/menus/{id?}/action','MenuController@storeAction');
	Route::delete('/menus/{id?}/action','MenuController@delAction');
	
	Route::get('/access','AccessController@home');
});

/*商店模块*/
Route::group(['namespace' =>"Admin", 'prefix' => 'app','middleware' => ['auth:api']], function () {
	Route::get('/store','StoreController@home');//所有商店
	Route::get('/store/{id?}','StoreController@show');//显示商店
	Route::post('/store','StoreController@store');//添加店铺
	Route::put('/store','StoreController@store');//修改店铺
	Route::delete('/store','StoreController@delete');//删除店铺	
});

/*商店模块*/
Route::group(['namespace' =>"Admin", 'prefix' => 'test','middleware' => ['auth:api']], function () {
	Route::get('/score', 'ScoreController@home');//所有商店
	Route::post('/score','ScoreController@import');//成绩导入
});

/*查询分数*/
Route::group(['namespace' =>"Home", 'prefix' => 'api','middleware' => []], function () {
	Route::any('/score/search', 'HomeController@search');//所有商店
});
